<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sf " uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="s " uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<title>编辑合同</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<%@ include file="/WEB-INF/common.jsp"%>

<link href="${path }/resources/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="${path }/resources/css/animate.css" rel="stylesheet">
<link href="${path }/resources/css/style.css?v=4.1.0" rel="stylesheet">

<!--dataTables css样式-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/jquery.dataTables.min.css">
<!--DataTables button扩展-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/form.css">
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/daterangepicker.css">

</head>
<style type="text/css" rel="stylesheet">
        #province {
            width:150px;
            margin-left:20px;
            display:inline-block;
        }
        #city{
            width:150px;
            margin-left:20px;
            display:inline-block;
        }
        #district{
            width:150px;
            margin-left:20px;
            display:inline-block;
        } 
        .frolabel{
        margin-top:10px;
        }
        .froinput{
        margin-left:-70px;
        }
</style>
<body class="gray-bg" style="">
<jsp:include page="/WEB-INF/loginCheck.jsp" />
	<div>
		<h1 style="margin-left:20px">生成维保报告书</h1>
	</div>
	<hr>
	<form id="defaultForm" action="${path }//.htm?" method="post"
		data-parsley-validate class="form-horizontal form-label-left">
		<div id="" barclass="panel-body" style="margin-top: 30px">
			<div  class="row" style = "margin-left:30px">
				<label class="col-md-1"
					for="last-name">项目名称
				</label>
				<div class="col-md-4">
					<select id="projectCharge" class="selectpicker " style="height:36px;font-size:18px" data-live-search="true" name="projectCharge" >
				     <option value="-1">选择合同名称</option>
				      <c:forEach items="${contract}" var="contract" >
							<option value="${contract.Id}"><c:out value="${contract.project_name}"/></option>
						</c:forEach>
					</select>
					<input type="hidden" id="projectHidden" value="${content.projectCharge}">				
				</div>
				<div class="col-md-4" >
					<button type="button" class="btn btn-success" onclick="showInfo()">查询</button>
				</div>
			</div>
	</div>

		<br>
		<div style="margin-top:20px">
			<h3 style="margin-left:20px">报告书封面内容</h3>
	    </div>
	    <hr>
		 <div class="row" style="margin-left:30px">
				<div class=" col-md-2">
					<select id="time" name="time" class="selectpicker form-control" onchange="javascript:doit();" data-live-search="true" name="identify" required="required">
						<option value="3">请选择</option>
						<option value="0">月</option>
						<option value="1">季</option>
						<option value="2">年</option>
					</select>
				</div>
				<div class="col-md-3">
			       <!--选择月-->
			       <input id="month" name="month" style="display:none;" class="form-control col-md-7 col-xs-12" type="text" onfocus="WdatePicker({dateFmt:'yyyy年MM月'})"/>
				   <!--选择年-->
					<input id="year" name="year" style="display:none;" class="form-control col-md-7 col-xs-12" type="text" onfocus="WdatePicker({dateFmt:'yyyy年'})"/>
				   <!--选择季-->
				   <input id="quarter" name="quarter" style="display:none;" class="form-control col-md-7 col-xs-12" type="text" onfocus="WdatePicker({dateFmt:'yyyy年MM季度',disabledDates:['....-0[5-9]-..','....-1[0-2]-..'],startDate:'%y-01-01'})"/>
				</div>
	     </div>
	     </form>
	     <div class="row" style="margin-left:20px;margin-top:10px">
	            <div class="col-md-2">
	            <label class="frolabel"
					for="last-name">项目名称：
				</label>
				</div>
				<div class="col-md-4"style="margin-left:-40px">
					<input type="text" id="name" value="" name="" placeholder="项目名称" class="form-control col-md-7 col-xs-12" readonly="readonly"> 
				</div>
				<div class="col-md-2">
	            <label
					for="last-name"class="frolabel">委托单位：
				</label>
				</div>
				<div class="col-md-4"style="margin-left:-40px">
					 <input type="text" id="proprietor" value="" name="" placeholder="委托单位" class="form-control col-md-7 col-xs-12" readonly="readonly" > 
				</div>
		</div>
		<div class="row" style="margin-left:20px;margin-top:10px">
	            <div class="col-md-3">
	            <label class="frolabel"
					for="last-name">维护保养机构名称：
				</label>
				</div>
				<div class="col-md-4"style="margin-left:-140px">
					<input type="text" id="enterprise" value="" name="" placeholder="维护保养机构名称" class="form-control col-md-7 col-xs-12" readonly="readonly"> 
				</div>
				<div class="col-md-3">
	            <label
					for="last-name"class="frolabel">维护保养机构资质：
				</label>
				</div>
				<div class="col-md-4"style="margin-left:-140px">
					 <input type="text" id="qualification" value="" name="" placeholder="维护保养机构资质" class="form-control col-md-7 col-xs-12" readonly="readonly"> 
				</div>
		</div>
	     <div style="margin-top:30px">
			<h3 style="margin-left:20px">建筑消防设施维护保养情况表</h3>
	     </div>
	     <hr>
	      
	     <div class="row" style="margin-left:20px;margin-top:10px">
	            <div class="col-md-2">
		            <label class="frolabel"
						for="last-name">起始时间：
					</label>
				</div>
				<div class="col-md-4"style="margin-left:-40px">
					<input type="text"  id="starttime" value="" name="" placeholder="起始时间" class="form-control col-md-7 col-xs-12" readonly="readonly"> 
				</div>
				<div class="col-md-2">
		            <label
						for="last-name"class="frolabel">结束时间：
					</label>
				</div>
				<div class="col-md-4"style="margin-left:-40px">
					 <input type="text" id="endtime" value="" name="" placeholder="结束时间" class="form-control col-md-7 col-xs-12" readonly="readonly" >  
				</div>
		</div>
		<div class="row" style="margin-left:20px;margin-top:10px">
	            <div class="col-md-2">
		            <label
						for="last-name"class="frolabel">地址：
					</label>
				</div>
				<div class="col-md-4
				"style="margin-left:-60px">
					 <input type="text" id="city" value="" name="" placeholder="地址"  class="form-control col-md-7 col-xs-12" readonly="readonly" >   
				</div>
		</div>
	     <div class="row">
				<div class="col-md-4 col-sm-6 col-xs-12 " style="margin-top:15px ;margin-left:45px">
					<button type="button" class="btn btn-success" onclick="create()">生成报告</button>
				</div>
			</div>
	     <hr>	    
	     <hr>
	</div>
	<script src="${path }/resources/js/jquery.min.js"></script>
	<!-- Peity-->
	<script src="${path }/resources/js/plugins/peity/jquery.peity.min.js"></script>
	<!-- datatables日期格式化 -->
	<script src="${path }/resources/js/moment.min.js"></script>
	<!-- Bootstrap table-->
	<script src="${path }/resources/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="${path }/resources/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

	<!-- 自定义js-->
	<script src="${path }/resources/js/content.js?v=1.0.0"></script>
	
	<!-- jQuery Validation plugin javascript-->
    <script src="${path }/resources/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${path }/resources/js/plugins/validate/messages_zh.min.js"></script>
   
   	<!-- jQuery form  -->
    <script src="${path }/resources/js/jquery.form.min.js"></script>
    
    <!-- layer javascript -->
    <script src="${path }/resources/js/plugins/layer/layer.min.js"></script>
	
    <!-- 省市联动 -->
	<script src="${path }/resources/js/distpicker.data.js"></script>
	<script src="${path }/resources/js/distpicker.js"></script>
	<script src="${path }/resources/js/main.js"></script>
	 <script src="${path }/resources/js/jquery.validate.min.js"></script>
	  <!-- my97 date-->
	<script src="${path }/resources/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">

/* 	window.onload=function(){

		var projectLeader = $("#projectLeaderHidden").val();//设置当前项目负责人选中项
		$("#projectCharge").val(projectLeader);

	} */
	function $(obj){return document.getElementById(obj);} 
	function show(objid) {$(objid).style.display='inline';} 
	function hidden(objid) {$(objid).style.display='none';} 
	function doit(){
		var time=$('time').value;
		if(time=="3"){hidden('month');hidden('year');hidden('quarter');}
		if(time=="0"){show('month');hidden('year');hidden('quarter');}
		if(time=="1"){show('quarter');hidden('month');hidden('year');}
		if(time=="2"){show('year');hidden('month');hidden('quarter');}
			}
	</script>
	<script type="text/javascript">
    function showInfo()
	{
    	/* var a = $("#projectCharge option:selected") .val();
    	alert(); */
    	var myselect=document.getElementById("projectCharge").value;
	     jQuery.ajax({
			url:"/firefighting/MaintenanceReport/getContentOfContract.htm",
			type:"POST",
			dataType:'json',
			data:{
				"contractId":myselect,
			},
			success:function(data)
			{
				var endtime=data.end_date;
				var endTime=moment(endtime).format("YYYY年MM月DD日");
				var starttime=data.sign_date;
				var startTime=moment(starttime).format("YYYY年MM月DD日");
				var name=data.project_name;
				var proprietor=data.proprietor;
				var City=data.city; 
				var enterprise=data.enterprise;
				var qualification=data.qualification;
				document.getElementById("endtime").value=endTime;
				document.getElementById("starttime").value=endTime;
				document.getElementById("name").value=name;
				document.getElementById("proprietor").value=proprietor;
				document.getElementById("city").value=City; 
				document.getElementById("enterprise").value=enterprise; 
				document.getElementById("qualification").value=qualification; 
			},
				error:function(data)
			{

			} 
		}); 
	}
    function create()
	{
    	var myselect=document.getElementById("projectCharge").value;
    	if(myselect==-1){
    		alert("请选择合同名称");
    		return false;
    	}
    	var type=document.getElementById("time").value;
		if(type=="3"){
			alert("请选择报告书类型");
			return false;
		}
		if(type=="0"){
			var planTime=document.getElementById("month").value;
		}
		if(type=="1"){
			var planTime=document.getElementById("quarter").value;	
		}
		if(type=="2"){
			var planTime=document.getElementById("year").value;
		}
 		if(planTime==""){
			alert("请输入时间");
			return false;
		} 
  	     jQuery.ajax({
			url:"/firefighting/MaintenanceReport/createPDF.htm",
			type:"POST",
			dataType:'json',
			data:{
				"planTime":planTime,
				"contractId":myselect,
				"type":type+1
				
			},
			success:function(data)
			{	if(data.flag==1){
				alert("生成成功");
			}else if(data.flag==2){
				alert("不能生成报告，计划内仍有任务未完成");
			}
			
			},
				error:function(data)
			{
				alert("生成失败");
			} 
		});   
	}
	</script>
</body>
</html>